<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>支付管理</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/animate.min.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/css/style.min.css?v=4.1.0" rel="stylesheet">
    <style type="text/css">

    </style>
</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <!-- Panel Other -->
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>提现管理</h5>
        </div>
        <div class="ibox-content">
            <div class="row row-lg">
                <div class="col-sm-12">
                    <div class="example-wrap">
                        <!-- start toolbar -->
                        <div class="col-sm-12">
                            <form class="form-horizontal" role="form" id="queryorderForm" autocomplete="off">
                                <div class="row">
                                <div class="col-sm-3 " >
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label" >提现订单号</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="提现订单号"  id="orderNo" name="orderNo">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3 " >
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label" >提现人编号</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="提现人编号"  id="personNum" name="personNum">
                                            </div>
                                           
                                        </div>
                                    </div>
                                    <div class="col-sm-3 " >
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label" >提现人</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="提现人"  id="personName" name="personName">
                                            </div>
                                           
                                        </div>
                                    </div>
                                 	<div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">开始时间</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="支付开始时间"  id="statrDate" name="statrDate">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">结束时间</label>
                                            <div class="col-sm-8">
                                                <input type="text" class="form-control" placeholder="支付结束时间"  id="endDate" name="endDate">
                                            </div>
                                        </div>
                                    </div>
                                   <div class="col-sm-3">
                                        <div class="form-group">
                                            <label class="col-sm-4 control-label">受理状态</label>
                                            <div class="col-sm-8">
                                                <select id="status" name="status" class="form-control">
                                                    <option value="">选择状态</option>
                                                    <option value="0">受理失败</option>
                                                    <option value="1">受理成功</option>
                                                    <option value="00">提现成功</option>
                                                    <option value="01">提现失败</option>
                                                    <option value="02">提现处理中</option>
                                                    <option value="03">提现待请求</option>
                                                    <option value="04">网络异常</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-sm-3">
                                    	<button type="button" class="btn btn-primary" id="queryWithdwarBtn">
                                            <span class="glyphicon glyphicon-search" aria-hidden="true"></span> 查询
                                        </button>
                                        <button type="button" class="btn btn-info" id="" onclick="location.reload();">
                                            <span class="glyphicon glyphicon-refresh" aria-hidden="true"></span> 刷新
                                        </button>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <!-- end toolbar -->
                        <div class="example">
                            <table id="withdwarTab" class="table" data-click-to-select="true" data-mobile-responsive="true">
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!-- End Panel Other -->
<script src="${pageContext.request.contextPath}/js/jquery.min.js?v=2.1.4"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js?v=3.3.6"></script>
<script src="${pageContext.request.contextPath}/js/content.min.js?v=1.0.0"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/bootstrap-table-mobile.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="${pageContext.request.contextPath}/js/plugins/layer/layer.min.js"></script>
 <script src="${pageContext.request.contextPath}/laydate5.0.7/laydate.js"></script>
<script src="${pageContext.request.contextPath}/js/public/ttbj-core.js"></script>
<script type="text/javascript">
var $table = $("#withdwarTab");
$(function () {
	//时间控件
	 laydate.render({
    	elem: '#statrDate',
    	type: 'datetime'
    });
	 laydate.render({
	    	elem: '#endDate',
	    	type: 'datetime'
	    });
    initTable();
    //条件查询
    $("#queryWithdwarBtn").click(function () {
        $table.bootstrapTable('refresh');	 //使用post提交
    });
   
});

function initTable() {
    $table.bootstrapTable({
    	dataType: "json",
        showColumns: true,
        singleSelect : true,
        pagination: true, //分页
        striped: true,
        cache: false,	//是否使用缓存，默认是true
        pageSize: 10,
        pageNumber: 1,
        queryParamsType: 'limit',
        smartDisplay: true,
        sidePagination: "server",
        method: "post",	//使用post提交
		queryParams: queryParams,
        url: '../withdraw/getWithdrawResultByPage.htm',
        contentType: 'application/x-www-form-urlencoded;charset=UTF-8',
        columns: [
            {
                title: "序号",
                align: 'center',
                formatter:function(value,row,index){
                    return index + 1;
                }
            },
            {
                title: "提现请求的提现订单号",
                field: "reqOrderNo",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "提现订单号",
                field: "orderNo",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "账户号",
                field: "accountNo",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "交易金额(元)",
                field: "amount",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "提现后账户余额(元)",
                field: "balance",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "提现后账户冻结金额(元)",
                field: "frozenAmt",
                align: 'center',
                valign: 'middle'
            },
            {
            	title: "提现受理状态",
                field: "status",
                align: 'center',
                valign: 'middle',
                formatter: function(value, row, index){
                    var status = "-";
                    if(row.status =="1"){
                    	status = '<span style="color:#5DBB5D;">受理成功</span>';
                    }else if(row.status == "0"){
                    	status ='<span style="color:#E25550;">受理失败</span>';
                    }
                    else if(row.status == "00"){
                    	status = '<span style="color:#5DBB5D;">提现成功</span>';
                    }
                    else if(row.status == "01"){
                    	status ='<span style="color:#E25550;">提现失败</span>';
                    }
                    else if(row.status == "02"){
                    	status ='<span style="color:#F59206;">提现处理中</span>';
                    }
                    else if(row.status == "03"){
                    	status ='<span style="color:#3CA2C0;">提现待请求</span>';
                    }
                    else if(row.status == "04"){
                    	status ='<span style="color:#0078CC;">网络异常</span>';
                    }
                    return status;
                }
            },
            {
                title: "应答信息描述",
                field: "retInfo",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "交易时间",
                field: "reqTime",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "提现人",
                field: "personName",
                align: 'center',
                valign: 'middle'
            },
            {
                title: "提现人编号",
                field: "personNum",
                align: 'center',
                valign: 'middle'
            },
           {
                title: "操作",
                align: 'center',
                formatter: function (value, row, index) {
                    var e = '';
                    if (row.status != "00"||row.status != "01"){
                    	e = '<button class="btn btn-xs btn-info" type="button" onclick="withdraw(\'' + row.accountNo +'\',\'' + row.orderNo +'\',\'' + row.status +  '\')">提现查询 </button> ';
                    }else{
                    	e = '-'
                    }
                    return e;
                }
            }
        ],
        onClickRow: function(row, $element, field){	//当点击某一行时，该行背景颜色改变
        	var trObj = $($element[0]);
        	var dataIndex = trObj.attr('data-index');
        	$("tr[data-index != '" + dataIndex + "']").removeAttr('style');
        	trObj.attr('style', 'background: #B4EEB4');
        }
    });
}
function queryParams(queryParamsType){
	var temp = {
		'limit': queryParamsType.limit,   //页面大小
		'offset': queryParamsType.offset,  //页码
		'orderNo': $.trim($('#orderNo').val()),
		'personNum': $.trim($('#personNum').val()), 
		'personName': $.trim($('#personName').val()),
		'status': $.trim($('#status').val()),
		'statrDate': $.trim($('#statrDate').val()),
		'endDate': $.trim($('#endDate').val()),
	};
	return temp;
}
//提现查询
function withdraw(accountNo,orderNo,status) {
	console.log(accountNo+"-"+orderNo+"-"+status);
	$.ajax({
        url: "../withdraw/withrawQuery.htm",
        cache: false,
        type: "post",
        dataType: "json",
        data:{'accountNo': accountNo,'orderNo':orderNo,'status':status},
        success: function (result) {
        	var message="";
			if(result.status=="0"){
				if(result.message =="00"){
					message = "成功"
	        	}else if(result.message =="01"){
	        		message = "失败"
	        	}
	        	else if(result.message =="02"){
	        		message = "处理中"
	        	}
	        	else if(result.message =="03"){
	        		message = "待请求"
	        	}
	        	else if(result.message =="04"){
	        		message = "网络异常"
	        	}
	        	layer.alert("提现状态："+message, {
	        		  skin: 'layui-layer-molv' //样式类名
	        		  ,closeBtn: 0
	        		});   		
        	}else if(result.status=="1"){
        		layer.alert(""+ result.message, {
	        		  skin: 'layui-layer-molv' //样式类名
	        		  ,closeBtn: 0
	        		});  
      	}
        }   
    });
	
}
</script>
</body>
</html>
